package jdesktop.appbar;

public class AppBarException extends RuntimeException
{
    private Reason reason;

    public AppBarException()
    {
    }

    public AppBarException(Reason reason)
    {
        this.reason = reason;
    }

    public Reason getReason()
    {
        return reason;
    }

    public AppBarException(String message)
    {
        super(message);
    }

    public AppBarException(String message, Reason reason)
    {
        super(message);
        this.reason = reason;
    }


    public AppBarException(String message, Throwable cause)
    {
        super(message, cause);
    }

    public AppBarException(Throwable cause)
    {
        super(cause);
    }

    public static enum Reason
    {
        /**
         * The app bar already has an associated window.
         * @see jdesktop.appbar.win32.WAppBar#register(java.awt.Window)
         */
        APPBAR_ALREADY_REGISTERED,

        /**
         * The Windows does not have a native peer.
         * @see jdesktop.appbar.win32.WAppBar#register(java.awt.Window)
         */
        APPBAR_NO_NATIVE_WINDOW,

        /**
         * The barsize set was less than zero.
         * @see jdesktop.appbar.win32.WAppBar#setBarSize(int)
         */
        ILLEGAL_BAR_SIZE,

        /**
         * An illegal edge was specified.
         * @see jdesktop.appbar.win32.WAppBar#setEdge(Edge)
         * @see jdesktop.appbar.win32.WAppBar#validateEdge
         */
        ILLEGAL_EDGE;

        /**
         * Creates a new exception with {@code reason} set to this value.
         * A little bit of syntactic sugar. Allows a new exception to be created more
         * conveniently. With static import of this class, then exception creation is
         * reduced to {@code REASON_CODE.exception()}
         * @return a newly created exception.
         */
        public AppBarException exception()
        {
            return new AppBarException(this);
        }

        public AppBarException exception(String message)
        {
            return new AppBarException(message, this);
        }


    }
}
